<template>
    <div class="header">
        商家列表
    </div>
    <!-- <div class="restaurant">
     <img src="../img/sj01.png" alt="" @click="Skip(1)">
     <div class="recommend-one">
        <h1>万家饺子（软件园店E18店）</h1>
         <p>￥15起送|￥3配送</p>
         <p>各种饺子炒菜</p>
     </div>
     <img src="../img/sj01.png" alt="" @click="Skip(2)">
     <div class="recommend-one">
        <h1>万家饺子（软件园店E18店）</h1>
         <p>￥15起送|￥3配送</p>
         <p>各种饺子炒菜</p>
     </div>

     <img src="../img/sj02.png" alt="" @click="Skip(3)">
     <div class="recommend-one">
        <h1>小锅饭豆腐馆（全运店）</h1>
         <p>￥15起送|￥3配送</p>
         <p>各种饺子炒菜</p>
     </div>
     <img src="../img/sj03.png" alt="" @click="Skip(4)">
     <div class="recommend-one">
        <h1>麦当劳麦乐送（全运路店）</h1>
         <p>￥15起送|￥3配送</p>
         <p>各种饺子炒菜</p>
     </div>
    
     <img src="../img/sj04.png" alt="" @click="Skip(5)">
     
     <div class="recommend-one">
        <h1>米村拌饭（浑南店）</h1>
         <p>￥15起送|￥3配送</p>
         <p>各种饺子炒菜</p>
     </div> 
     <img src="../img/sj05.png" alt="" @click="Skip(6)">
     <div class="recommend-one">
        <h1>申记串道（中海康城店）</h1>
         <p>￥15起送|￥3配送</p>
         <p>各种饺子炒菜</p>
     </div>
     
     <img src="../img/sj06.png" alt="" @click="Skip(7)">
     <div class="recommend-one">
        <h1>半亩良田排骨米饭</h1>
         <p>￥15起送|￥3配送</p>
         <p>各种饺子炒菜</p>
     </div>
       
     <img src="../img/sj07.png" alt="" @click="Skip(8)">
     <div class="recommend-one">
        <h1>茶兮鲜果饮品（国际软件园店）</h1>
         <p>￥15起送|￥3配送</p>
         <p>各种饺子炒菜</p>
     </div>
      
     <img src="../img/sj08.png" alt="" @click="Skip(9)">
     <div class="recommend-one">
        <h1>唯一水果捞（软件园E18店）</h1>
         <p>￥15起送|￥3配送</p>
         <p>各种饺子炒菜</p>
     </div>
  
     <img src="../img/sj09.png" alt="" @click="Skip(10)">
     <div class="recommend-one">
        <h1>满园春饼（全运路店）</h1>
         <p>￥15起送|￥3配送</p>
         <p>各种饺子炒菜</p> -->
     
     <!-- </div> -->

    <!-- </div> -->
     <ul class="business">
        <li v-for="item in businessArr" @click="toBusinessInfo(item.businessId)" v-bind:key="item.bussinessId" class="businessList-li">
            <div class="business-img">
                <img :src="item.businessImg"/>
                <div class="business-img-quantity" v-show="item.quantity>0">{{item.quantity}}</div>
            </div>
            <div class="business-info">
                <h3>{{item.businessName}}</h3>
                <p>&#165;{{ item.starPrice }}起送| &#165;{{ item.deliveryPrice }}配送</p>
                <p>{{ item.businessExplain }}</p>
            </div>
        </li>
     </ul>
    <Footer></Footer>
</template>
<style>


.header{
    width: 100%;
    height: 100px;
    
    color: #ffffff;
    background-color: #0097ff;
    font-size: 50px;
    text-align: center;
}

.business{
    
    width: 500px;
}

.businessList-li{
    display: flex;
}
.business-info{
    text-align: left;
}
    
  




</style>
<script>
export default{
    name:"bussnessList",
    data(){
        return{
            orderTypeId:this.$route.query.orderTypeId,
            businessArr:[],
            user:{}
        }
    },
    created(){
        this.user = this.$getSessionStorage("user");
        this.$axios.post('BusinessController/listBusinessByOrderTypeId',this.$qs.stringify({
        orderTypeId:this.orderTypeId
        })).then(response =>{
            this.businessArr = response.data;
            if(this.user !=null){
                this.listCartByUserId();
            }
        }).catch(error =>{
            console.error(error);
        })
    },
    methods:{
        toBusinessInfo(businessId){
           // this.$router.push({path:'/bussnessInfor'});
            console.log('列表:'+businessId);
            this.$router.push({path:'/bussnessInfor',query:{businessId:businessId}});
 
        },
        listCartByUserId(){
            this.$axios.post('CartController/ListCart',this.$qs.stringify({
                userId:this.user.userId

            })).then(response =>{
                let cartArr = response.data;
                for(let businessItem of this.businessArr){
                    businessItem.quantity=0;
                    for(let cartItem of cartArr){
                        if(cartItem.businessId == businessItem.businessId){
                            businessItem.quantity +=cartItem.quantity;
                        }
                    }
                }
                this.businessArr.sort();
                console.log(this.businessArr);
                
            }).catch(error =>{
                console.log(error);
                
            });
        }
    }
}
</script>